#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
void merge(int* nums1, int nums1Size, int m, int* nums2, int nums2Size, int n)
{
    int i = 0;
    int j = 0;
    int arr[10] = {0};
    int k = 0;
    while (k < m + n)
    {
        if (i == m)
        {
            arr[k] = nums2[j];
            j++;
            k++;
        }
        else if (j == n)
        {
            arr[k] = nums1[i];
            i++;
            k++;
        }
        else if(nums1[i] < nums2[j])
        {
            arr[k] = nums1[i];
            i++;
            k++;
        }
        else
        {
            arr[k] = nums2[j];
            j++;
            k++;
        }

    }
    for (i = 0; i < m + n; i++)
    {
        nums1[i] = arr[i];
    }
}
int cmp(void* e1, void* e2)
{
    return *((int*)e1) - *((int*)e2);
}
int removeElement1(int* nums, int numsSize, int val)
{
    int i = numsSize;
    int j = 0;
    for (j = 0; j < numsSize; j++)
    {
        if (nums[j] == val)
        {
            int n;
            for (n = j; n < i - 1; n++)
            {
                nums[n] = nums[n + 1];
            }
            i--;
            j--;
        }
    }
    return i;
}
int removeElement2(int* nums, int numsSize, int val)
{
    int i = 0;
    int j = 0;
    for (j = 0; j < numsSize; j++)
    {
        if (nums[j] != val)
        {
            nums[i] = nums[j];
            i++;
        }
    }
    return i;
}
int main()
{
    int arr1[10] = {2,4,6,3,7,9,2,23,2,8};
    //int arr2[3]= {2,5,6};
    //merge(arr1, 6, 3, arr2, 3, 3);
    //qsort(arr1,10,sizeof(int),cmp);
    int j = removeElement1(arr1,10,2);

    for (int i = 0; i < j; i++)
    {
        printf("%d\n", arr1[i]);
    }
    return 0;
}